package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.domain.Region;
import cn.wolfcode.luowowo.article.query.RegionQuery;
import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.article.service.IRegionService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 猫教授
 * @date 2019/8/9 15:36
 */
@Controller
@RequestMapping("region")
public class RegionController {
    @Reference
    private IRegionService regionService;
    @Reference
    private IDestinationService destinationService;


    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") RegionQuery qo, Model model) {
      PageInfo<Region> pageInfo=regionService.listAll(qo);
      model.addAttribute("pageInfo",pageInfo);
      return "region/list";
    }

    /**
     * 区域关联目的地下拉框的列表
     * @param deep 显示级别.小于3
     * @param model
     * @return
     */

    @RequestMapping("/getDestByDeep")
    @ResponseBody
    public List<Destination> getDestByDeep(int deep, Model model) {

        return destinationService.selectDestByDeep(deep);
    }






}
